//
//  VERemondHeadTableViewCell.m
//  VEMoneyPorject
//
//  Created by BlueWind on 2018/9/10.
//  Copyright © 2018年 陈建. All rights reserved.
//  推荐头cell

#import "VERemondHeadTableViewCell.h"

@implementation VERemondHeadTableViewCell

{
    UIImageView *_headImageView;
    
    UILabel *_nickNameLabel;
    
    UILabel *_time;
    
}


/** 返回循环利用的cell */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self= [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self loadDefaultSetting];
    }
    return self;
}

/** 加载默认UI元素和需要的数据 */
- (void)loadDefaultSetting {
    
    UIView *line = [UIView new];
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(GAP15);
        make.right.equalTo(self.contentView).offset(-GAP15);
        make.height.mas_equalTo(0.5);
    }];
    line.backgroundColor = kRGBColor(237, 237, 237);
    
    _headImageView = [UIImageView new];
    [self.contentView addSubview:_headImageView];
    [_headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView).offset(5);
        make.left.equalTo(self.contentView).offset(GAP15);
        make.size.mas_equalTo(CGSizeMake(50, 50));
    }];
    _headImageView.layerCornerRadius = 25;
    _headImageView.image = [UIImage imageNamed:@"First_PlaceHolder"];
    
    _nickNameLabel = [UILabel new];
    [self.contentView addSubview:_nickNameLabel];
    [_nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self->_headImageView.mas_centerY);
        make.left.equalTo(self->_headImageView.mas_right).offset(GAP8);
    }];
    _nickNameLabel.text = @"其实都没有";
    _nickNameLabel.textColor = [UIColor redColor];
    _time.font = kFont(15);
    
    _time = [UILabel new];
    [self.contentView addSubview:_time];
    [_time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self->_headImageView.mas_centerY).offset(5);
        make.left.equalTo(self->_nickNameLabel);
    }];
    _time.textColor = [UIColor colorWithHexString:kDetailTextGrayBlackColor];
    _time.font = kFont(12);
    _time.text = @"21分钟前";
}

- (void)setModel:(VERemondModel *)model {
    
    _model = model;
    [_headImageView setImageWithURL:[NSURL URLWithString:model.faburenphoto] palceHolderImage:[UIImage imageNamed:@"头像"]];
    _nickNameLabel.text = model.faburen;
    _time.text = [NSDate dateDescriptionWithTargetDate:model.DYNAMICTIME andTargetDateFormat:@"yyyy/MM/dd HH:mm:ss"];
}


@end
